<template>

	<view class="approval-footer">
		<view class="pass-footer">
			<view class="submit" @click="handleConfirm(2)">验收不通过</view>
			<view class="pass" @click="handleConfirm(1)">验收通过</view>

		</view>
		<u-modal :show="showConfirm" @cancel="showConfirm=false" @confirm="submit()" :showCancelButton="true"
			title="提示" content='是否确认提交?'></u-modal>
	</view>
</template>

<script>
	import {
		checkResult,
	} from '@/api/maintain'
	export default {
		props: {
			id: {},
			type: {

			}, // 1保养工单
		},

		data() {
			return {
				showConfirm: false,
				flag: ''

			}
		},

		onShow() {

		},
		created() {

		},
		methods: {
			handleConfirm(index) {
				this.flag=index
				this.showConfirm = true
			},
			submit() {
				const flag=this.flag

				if (this.type === '1') {
					const paramData = {
						id: this.id,
						checkResult: flag
					}
					uni.showLoading({
						mask: true,
						title: '加载中',
					})
					this.showConfirm = false
					checkResult(paramData).then(response => {
						if (response.code === 200) {
							uni.showToast({
								icon: 'none',
								title: '提交成功',
								mask: true,
								duration: 2000,
							})
							setTimeout(() => {
								uni.hideLoading()
								this.$emit('getDetail')
							}, 2000)
						} else {

							uni.hideLoading()
						}


					})
				}

			}

		}
	}
</script>

<style lang="scss" scoped>
	.pass-footer {
		width: 690rpx;
		height: 104rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 70rpx auto 0 auto;

		.submit {
			background: #FF654E;
			border-radius: 20rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			font-weight: 400;
			color: #FFFFFF;
			width: 312rpx;
			height: 104rpx;
		}

		.pass {
			width: 312rpx;
			height: 104rpx;
			background: #407FFF;
			border-radius: 20rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>
